-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manual CPFP #413
base: master
Are you sure you want to change the base?
Manual CPFP #413
Conversation
64efaf3
to
cdc6c11
Compare
645a767
to
d4c0832
Compare
A simple test for |
39be8bd
to
1d90a44
Compare
I am unable to figure out a simple way of testing CPFPing multiple SpendTransactions, if there is a simpler scheme that I can follow please let me know. The Current CPFP is able to terminate invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at the test for manual CPFP of multiple Spend transactions, which looks valid but cluttered.
446283c
to
f217739
Compare
2df277a
to
aa275ff
Compare
Is this ready for review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments on the implementation for now. I'll review the tests tomorrow.
Why do you update the tests/servers/
submodules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message handler in the bitcoind thread is wrong. It would return which would stop the loop, and obviously, make the program crash on shutdown or any further tentative to use the bitcoind thread (such as for another manual CPFP). I guess the reason you have so many small tests is a workaround for this bug...
66048ee
to
a81036a
Compare
e0ac86a
to
6b497b4
Compare
6b497b4
to
8710e1b
Compare
Untested, but i think you can use this to externally fund the CPFP wallet: diff --git a/tests/test_framework/revault_network.py b/tests/test_framework/revault_network.py
index 0a840f8..8dfa68e 100644
--- a/tests/test_framework/revault_network.py
+++ b/tests/test_framework/revault_network.py
@@ -3,6 +3,7 @@ import logging
import os
import random
+from bip380.descriptors import Descriptor
from ephemeral_port_reserve import reserve
from nacl.public import PrivateKey as Curve25519Private
from test_framework import serializations
@@ -541,6 +542,13 @@ class RevaultNetwork:
return created_vaults
+ def fund_cpfp(self, amount):
+ """Send a coin worth this value to the CPFP descriptor"""
+ der_desc = Descriptor.from_str(str(self.cpfp_desc))
+ der_desc.derive(0)
+ decoded = self.bitcoind.rpc.decodescript(der_desc.script_pubkey.hex())
+ self.bitcoind.rpc.sendtoaddress(decoded["address"], amount)
+
def secure_vault(self, vault):
"""Make all stakeholders share signatures for all revocation txs"""
deposit = f"{vault['txid']}:{vault['vout']}" |
This should fix the unit tests CI, and also fixes the configuration of the functional tests CI (thanks for reporting it!): #423. |
8710e1b
to
32d0599
Compare
match tx.cpfp_txin(cpfp_descriptor, &revaultd.secp_ctx) { | ||
Some(txin) => txins.push(txin), | ||
None => { | ||
log::error!("No CPFP txin for tx '{}'", tx.txid()); | ||
return Ok(txids.into_iter().collect()); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than returning all the transactions, I need to throw an error here. I'm not sure which one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create a new enum variant for it if none other fit.
def get_unvault_txids(wallet, vaults): | ||
unvault_txids = [] | ||
for vault in vaults: | ||
deposit = f"{vault['txid']}:{vault['vout']}" | ||
unvault_psbt = serializations.PSBT() | ||
unvault_b64 = wallet.rpc.listpresignedtransactions([deposit])[ | ||
"presigned_transactions" | ||
][0]["unvault"] | ||
unvault_psbt.deserialize(unvault_b64) | ||
unvault_psbt.tx.calc_sha256() | ||
unvault_txids.append(unvault_psbt.tx.hash) | ||
return unvault_txids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good practice to import functions from other test files? This function is present in test_misc.py
. I can also move it into a different file. Let me know what would be the best approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make it a method of the RevaultNetwork
class.
Along with tests.
This PR is to maintain code corresponding to the RFC that is being discussed for the addition of manual CPFP command as a JSONRPC API in revaultd. RFC is present here. #411 is the corresponding milestone tracker